<template>
  <div class="home" v-infinite-scroll="load" >
    <Header :title="'资讯'"></Header>
    <div class="content">
      <div class="left">
        <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane label="推荐" name="tuijian"></el-tab-pane>
          <el-tab-pane label="国内" name="guonei"></el-tab-pane>
          <el-tab-pane label="国际" name="guoji"></el-tab-pane>
          <el-tab-pane label="娱乐" name="yule"></el-tab-pane>
          <el-tab-pane label="体育" name="tiyu"></el-tab-pane>
          <el-tab-pane label="军事" name="junshi"></el-tab-pane>
          <el-tab-pane label="科技" name="keji"></el-tab-pane>
          <el-tab-pane label="财经" name="caijing"></el-tab-pane>
          <el-tab-pane label="时尚" name="shishang"></el-tab-pane>
          <el-tab-pane label="游戏" name="youxi"></el-tab-pane>
          <el-tab-pane label="汽车" name="qiche"></el-tab-pane>
          <el-tab-pane label="健康" name="jiankang"></el-tab-pane>
        </el-tabs>
        <div v-for="(item, index) in list" :key="index" class="card" @click="detail(item.uniquekey)">
          <div class="title">
            {{ item.title }}
          </div>
          <div class="img">
            <div class="img-item" v-if="item.thumbnail_pic_s" style="margin-right: 10px"><img
                :src="item.thumbnail_pic_s" alt=""></div>
            <div class="img-item" v-if="item.thumbnail_pic_s02" style="margin-right: 10px"><img
                :src="item.thumbnail_pic_s02" alt=""></div>
            <div class="img-item"><img v-if="item.thumbnail_pic_s03" :src="item.thumbnail_pic_s03" alt=""></div>
          </div>
          <div class="bottom">
            <span style="margin-right: 20px">{{ item.category }}</span>
            <span style="margin-right: 20px">{{ item.author_name }}</span>
            <span style="margin-right: 20px">{{ item.date }}</span>
          </div>
        </div>
      </div>
      <div class="right">
        <div class="title">
          <img src="../assets/logo.jpg" alt="" style="width: 100px;height: 100px;border-radius: 50%">
          <div style="font-size: 18px;letter-spacing: 1px;color: #666">忧郁的悟空仔</div>
          <div style="width: 100%;display: flex">
            <div style="flex: 1;padding: 5px 0 5px 8px"><img style="width: 100%" src="../assets/gongzhonghao.jpg"
                                                             alt=""></div>
            <div style="flex: 1;padding: 5px 8px 5px 0"><img style="width: 100%" src="../assets/xiaochengxu.jpg" alt="">
            </div>
          </div>
        </div>
      </div>
    </div>
    <div v-if="loading">加载中...</div>
    <div v-if="noMore">没有更多了</div>
  </div>
</template>

<script>
  // @ is an alias to /src
  import Header from '@/components/header.vue'

  export default {
    name: 'Home',
    components: {
      Header
    },
    computed: {
      noMore () {
        return this.list >= 20
      },
      disabled () {
        return this.loading || this.noMore
      }
    },
    data() {
      return {
        activeName: 'tuijian',
        list: [],
        page: 1,
        page_size: 10,
        loading: false
      }
    },
    mounted() {
      this.initData()
    },
    methods: {
      load() {
        this.loading = true
        // let count = this.list.length
        // setTimeout(() => {
        //   this.list.push({
        //     "uniquekey": "2617c3b3a30d71d100691eb88b0e715b" + count,
        //     "title": count + "高安两男子被刑拘，皆因干了这勾当！",
        //     "date": "2021-08-02 17:18:00",
        //     "category": "头条",
        //     "author_name": "谢钱碧",
        //     "url": "https://mini.eastday.com/mobile/210802171840026343502.html",
        //     "thumbnail_pic_s": "https://dfzximg02.dftoutiao.com/news/20210802/20210802171840_5c5fcf2e61290bdbc9e5bf691797993c_1_mwpm_03201609.jpeg",
        //     "thumbnail_pic_s02": "https://dfzximg02.dftoutiao.com/news/20210802/20210802171840_5c5fcf2e61290bdbc9e5bf691797993c_2_mwpm_03201609.jpeg",
        //     "thumbnail_pic_s03": "https://dfzximg02.dftoutiao.com/news/20210802/20210802171840_5c5fcf2e61290bdbc9e5bf691797993c_3_mwpm_03201609.jpeg",
        //     "is_content": "0"
        //   })
        //   this.loading = false
        // }, 2000)
      },
      handleClick() {
      },
      initData() {
        this.list = [
          {
            "uniquekey": "2617c3b3a30d71d100691eb88b0e715b",
            "title": "高安两男子被刑拘，皆因干了这勾当！",
            "date": "2021-08-02 17:18:00",
            "category": "头条",
            "author_name": "谢钱碧",
            "url": "https://mini.eastday.com/mobile/210802171840026343502.html",
            "thumbnail_pic_s": "https://dfzximg02.dftoutiao.com/news/20210802/20210802171840_5c5fcf2e61290bdbc9e5bf691797993c_1_mwpm_03201609.jpeg",
            "thumbnail_pic_s02": "https://dfzximg02.dftoutiao.com/news/20210802/20210802171840_5c5fcf2e61290bdbc9e5bf691797993c_2_mwpm_03201609.jpeg",
            "thumbnail_pic_s03": "https://dfzximg02.dftoutiao.com/news/20210802/20210802171840_5c5fcf2e61290bdbc9e5bf691797993c_3_mwpm_03201609.jpeg",
            "is_content": "0"
          },
          {
            "uniquekey": "c4f4130a396b7199dc65811bf486ceaf",
            "title": "科技成果转化视角下的职务发明该如何认定？（上）",
            "date": "2021-08-02 17:18:00",
            "category": "头条",
            "author_name": "健康界",
            "url": "https://mini.eastday.com/mobile/210802171839583490313.html",
            "thumbnail_pic_s": "https://dfzximg02.dftoutiao.com/news/20210802/20210802171839_ce384618dff858bf429d379a600d683e_1_mwpm_03201609.png",
            "thumbnail_pic_s02": "https://dfzximg02.dftoutiao.com/news/20210802/20210802171839_ce384618dff858bf429d379a600d683e_2_mwpm_03201609.png",
            "thumbnail_pic_s03": "https://dfzximg02.dftoutiao.com/news/20210802/20210802171839_ce384618dff858bf429d379a600d683e_3_mwpm_03201609.png",
            "is_content": "0"
          },
          {
            "uniquekey": "3102cde27a06774e322e8d57f1645025",
            "title": "河南强降雨已致302人遇难，其中郑州292人",
            "date": "2021-08-02 17:18:00",
            "category": "头条",
            "author_name": "中国新闻网",
            "url": "https://mini.eastday.com/mobile/210802171839093455788.html",
            "thumbnail_pic_s": "https://dfzximg02.dftoutiao.com/news/20210802/20210802171839_20b02f9d71cb14a55b588abd6b43fe7a_1_mwpm_03201609.jpeg",
            "thumbnail_pic_s02": "https://dfzximg02.dftoutiao.com/news/20210802/20210802171839_20b02f9d71cb14a55b588abd6b43fe7a_2_mwpm_03201609.jpeg",
            "is_content": "0"
          },
          {
            "uniquekey": "07a39ecfb7a471dba63100129efee716",
            "title": "广西一小孩逛商场偷走手机，家长发现后主动带儿子到公安机关自首",
            "date": "2021-08-02 17:18:00",
            "category": "头条",
            "author_name": "消费日报社",
            "url": "https://mini.eastday.com/mobile/210802171837586265536.html",
            "thumbnail_pic_s": "https://dfzximg02.dftoutiao.com/news/20210802/20210802171837_b862eb87ce086202b5c4492cb51f898f_1_mwpm_03201609.jpeg",
            "thumbnail_pic_s02": "https://dfzximg02.dftoutiao.com/news/20210802/20210802171837_b862eb87ce086202b5c4492cb51f898f_2_mwpm_03201609.jpeg",
            "thumbnail_pic_s03": "https://dfzximg02.dftoutiao.com/news/20210802/20210802171837_b862eb87ce086202b5c4492cb51f898f_3_mwpm_03201609.jpeg",
            "is_content": "0"
          },
          {
            "uniquekey": "b9976143127f55aefd7e256de8cd5720",
            "title": "【护航新征程】江西余干：黑手！医院里被卷走的治病钱！",
            "date": "2021-08-02 17:18:00",
            "category": "头条",
            "author_name": "江西公安",
            "url": "https://mini.eastday.com/mobile/210802171835079559118.html",
            "thumbnail_pic_s": "https://dfzximg02.dftoutiao.com/news/20210802/20210802171835_ab6031adaadb7874bd4a943008aa31d6_1_mwpm_03201609.jpeg",
            "thumbnail_pic_s02": "https://dfzximg02.dftoutiao.com/news/20210802/20210802171835_ab6031adaadb7874bd4a943008aa31d6_2_mwpm_03201609.jpeg",
            "thumbnail_pic_s03": "https://dfzximg02.dftoutiao.com/news/20210802/20210802171835_ab6031adaadb7874bd4a943008aa31d6_3_mwpm_03201609.jpeg",
            "is_content": "0"
          }
        ]
        // window.axios.get(`api/Oil/oilInfo`).then(res => {
        //   console.log(res)
        // })
      },
      detail(id) {
        this.$router.push(`/detail/${id}`)
      }
    }
  }
</script>

<style>
  .content .left .el-tabs__item {
    font-size: 18px;
  }
</style>
<style lang="scss" scoped>
  .home {
    padding: 20px;
    width: 1060px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    margin: 0 auto;
    font-size: 20px;
    font-weight: 500;
    line-height: 28px;
    word-break: break-all;
    color: #333;

    .content {
      width: 1020px;
      display: flex;
      margin-top: 10px;

      .left {
        width: 720px;
        padding-right: 10px;

        .card {
          margin: 15px 0;
          cursor: pointer;

          .title {
            margin-bottom: 10px;
          }

          .img {
            display: flex;
            margin-bottom: 10px;

            .img-item {
              flex: 1 1 33.33%;
              height: 120px;

              img {
                height: 100%;
                width: auto;
              }
            }
          }

          .bottom {
            font-size: 14px;
            color: #999999;
          }
        }
      }

      .right {
        flex: 1;
        display: flex;
        justify-content: center;

        .title {
          width: 300px;
          height: 400px;
          text-align: center;
          border: solid 1px #f9f9f9;
          box-shadow: 2px 2px 2px #f9f9f9;
          border-radius: 5px;
          padding: 20px 0;
        }
      }
    }
  }
</style>
